<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 5.4.0">
  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">

<link rel="stylesheet" href="/css/main.css">


<link rel="stylesheet" href="/lib/font-awesome/css/all.min.css">

<script id="hexo-configurations">
    var NexT = window.NexT || {};
    var CONFIG = {"hostname":"inkgn.gitee.io","root":"/","scheme":"Muse","version":"7.8.0","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12,"onmobile":false},"copycode":{"enable":false,"show_result":false,"style":null},"back2top":{"enable":true,"sidebar":false,"scrollpercent":false},"bookmark":{"enable":false,"color":"#222","save":"auto"},"fancybox":false,"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"algolia":{"hits":{"per_page":10},"labels":{"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}},"localsearch":{"enable":false,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}}};
  </script>

  <meta name="description" content="CSS3 制作的春节整蛊红包最近在模仿群里大佬们做个答题得红包的页面，捣捣鼓鼓到现在算是能拿得出手了。虽然只是个简单的页面但是遇到的问题还真是不少，下面就说一下制作流程和过程中遇到的一些问题，first  和我一起看看效果图吧！">
<meta property="og:type" content="article">
<meta property="og:title" content="CSS3 制作的春节整蛊红包">
<meta property="og:url" content="https://inkgn.gitee.io/2020/02/05/list6/index.html">
<meta property="og:site_name" content="静水深流">
<meta property="og:description" content="CSS3 制作的春节整蛊红包最近在模仿群里大佬们做个答题得红包的页面，捣捣鼓鼓到现在算是能拿得出手了。虽然只是个简单的页面但是遇到的问题还真是不少，下面就说一下制作流程和过程中遇到的一些问题，first  和我一起看看效果图吧！">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="http://blog-1253246719.coscd.myqcloud.com/blog/envelop/envelope.png">
<meta property="article:published_time" content="2020-02-05T15:40:34.000Z">
<meta property="article:modified_time" content="2020-02-05T15:40:34.000Z">
<meta property="article:author" content="yinks">
<meta property="article:tag" content="jquery">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="http://blog-1253246719.coscd.myqcloud.com/blog/envelop/envelope.png">

<link rel="canonical" href="https://inkgn.gitee.io/2020/02/05/list6/">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome : false,
    isPost : true,
    lang   : 'zh-CN'
  };
</script>

  <title>CSS3 制作的春节整蛊红包 | 静水深流</title>
  






  <noscript>
  <style>
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header { opacity: initial; }

  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

</head>

<body itemscope itemtype="http://schema.org/WebPage">
  <div class="container use-motion">
    <div class="headband"></div>

    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏">
      <span class="toggle-line toggle-line-first"></span>
      <span class="toggle-line toggle-line-middle"></span>
      <span class="toggle-line toggle-line-last"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <h1 class="site-title">静水深流</h1>
      <span class="logo-line-after"><i></i></span>
    </a>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
    </div>
  </div>
</div>




<nav class="site-nav">
  <ul id="menu" class="main-menu menu">
        <li class="menu-item menu-item-home">

    <a href="/" rel="section"><i class="fa fa-home fa-fw"></i>首页</a>

  </li>
        <li class="menu-item menu-item-categories">

    <a href="/categories/categories" rel="section"><i class="fa fa-th fa-fw"></i>分类</a>

  </li>
        <li class="menu-item menu-item-archives">

    <a href="/archives/" rel="section"><i class="fa fa-archive fa-fw"></i>归档</a>

  </li>
        <li class="menu-item menu-item-motto">

    <a href="/motto/motto" rel="section"><i class="fa fa-book fa-fw"></i>古训</a>

  </li>
        <li class="menu-item menu-item-about">

    <a href="/about/me" rel="section"><i class="fa fa-user fa-fw"></i>关于</a>

  </li>
  </ul>
</nav>




</div>
    </header>

    
  <div class="back-to-top">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>


    <main class="main">
      <div class="main-inner">
        <div class="content-wrap">
          

          <div class="content post posts-expand">
            

    
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://inkgn.gitee.io/2020/02/05/list6/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="https://blog-1253246719.cos.ap-chengdu.myqcloud.com/blog/user_info/face">
      <meta itemprop="name" content="yinks">
      <meta itemprop="description" content="长路漫漫，半程风雨，半程春">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="静水深流">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          CSS3 制作的春节整蛊红包
        </h1>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2020-02-05 23:40:34" itemprop="dateCreated datePublished" datetime="2020-02-05T23:40:34+08:00">2020-02-05</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-folder"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/jquery/" itemprop="url" rel="index"><span itemprop="name">jquery</span></a>
                </span>
            </span>

          

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
        <h3 id="CSS3-制作的春节整蛊红包"><a href="#CSS3-制作的春节整蛊红包" class="headerlink" title="CSS3 制作的春节整蛊红包"></a>CSS3 制作的春节整蛊红包</h3><p>最近在模仿群里大佬们做个答题得红包的页面，捣捣鼓鼓到现在算是能拿得出手了。<br>虽然只是个简单的页面但是遇到的问题还真是不少，下面就说一下制作流程和过程中遇到的一些问题，first  和我一起看看效果图吧！</p>
<center>
<img src="http://blog-1253246719.coscd.myqcloud.com/blog/envelop/envelope.png"></img>
</center>

<h4 id="制作流程"><a href="#制作流程" class="headerlink" title="制作流程"></a>制作流程</h4><ul>
<li>基本样式</li>
<li>红包领取逻辑</li>
<li>QQ面对面红包链接</li>
</ul>
<p><strong>基础样式</strong></p>
<p>HTML分为两部分<code>header</code>部分写红包头部，<code>main</code>是内容区域</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line">&lt;div <span class="class"><span class="keyword">class</span></span>=<span class="string">&quot;option&quot;</span>&gt;</span><br><span class="line">       <span class="xml"><span class="tag">&lt;<span class="name">header</span>&gt;</span></span></span><br><span class="line"><span class="xml">           <span class="tag">&lt;<span class="name">img</span> <span class="attr">src</span>=<span class="string">&quot;image/tx.jpg&quot;</span> <span class="attr">alt</span>=<span class="string">&quot;头像&quot;</span>&gt;</span></span></span><br><span class="line"><span class="xml">       <span class="tag">&lt;/<span class="name">header</span>&gt;</span></span></span><br><span class="line"><span class="xml"></span></span><br><span class="line"><span class="xml">       <span class="tag">&lt;<span class="name">main</span>&gt;</span></span></span><br><span class="line"><span class="xml">           <span class="tag">&lt;<span class="name">h2</span>&gt;</span> 祝你新春快乐<span class="tag">&lt;/<span class="name">h2</span>&gt;</span></span></span><br><span class="line"><span class="xml">           <span class="tag">&lt;<span class="name">a</span> <span class="attr">href</span>=<span class="string">&quot;javascript:;&quot;</span>&gt;</span>前端大白 敬上！<span class="tag">&lt;/<span class="name">a</span>&gt;</span></span></span><br><span class="line"><span class="xml">           <span class="tag">&lt;<span class="name">button</span> <span class="attr">class</span>=<span class="string">&quot;btn&quot;</span>&gt;</span>点击拆开<span class="tag">&lt;/<span class="name">button</span>&gt;</span></span></span><br><span class="line"><span class="xml">       <span class="tag">&lt;/<span class="name">main</span>&gt;</span></span></span><br><span class="line"><span class="xml">   <span class="tag">&lt;/<span class="name">div</span>&gt;</span></span></span><br></pre></td></tr></table></figure>
<p>CSS  写了基本样式，为了增加效果写了个弹出动画</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br></pre></td><td class="code"><pre><span class="line">.option &#123;</span><br><span class="line"> <span class="attr">width</span>: 22rem;</span><br><span class="line">height: 30rem;</span><br><span class="line">border-radius: 12px;</span><br><span class="line">overflow: hidden;</span><br><span class="line">opacity: <span class="number">0</span>;</span><br><span class="line">margin: 6rem auto;</span><br><span class="line">background-color: #D13D4B;</span><br><span class="line">animation: mymove .6s cubic-bezier(<span class="number">0.68</span>, -<span class="number">0.55</span>, <span class="number">0.27</span>, <span class="number">1.55</span>) .9s forwards;</span><br><span class="line">-webkit-animation: mymove .6s cubic-bezier(<span class="number">0.68</span>, -<span class="number">0.55</span>, <span class="number">0.27</span>, <span class="number">1.55</span>) .9s forwards;</span><br><span class="line">-moz-animation: mymove .6s cubic-bezier(<span class="number">0.68</span>, -<span class="number">0.55</span>, <span class="number">0.27</span>, <span class="number">1.55</span>) .9s forwards;</span><br><span class="line">-o-animation: mymove .6s cubic-bezier(<span class="number">0.68</span>, -<span class="number">0.55</span>, <span class="number">0.27</span>, <span class="number">1.55</span>) .9s forwards;   </span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line">.option header &#123;</span><br><span class="line">   <span class="attr">position</span>: relative;</span><br><span class="line">   width: <span class="number">100</span>%;</span><br><span class="line">   height: 22rem;</span><br><span class="line">   left: <span class="number">0</span>;</span><br><span class="line">   top: -13rem;</span><br><span class="line">   border-radius: <span class="number">45</span>%;</span><br><span class="line">   background-color: #EB4455;</span><br><span class="line">   box-shadow: <span class="number">0</span> -2px 10px rgba(<span class="number">30</span>, <span class="number">30</span>, <span class="number">30</span>, <span class="number">.8</span>);</span><br><span class="line"> &#125;</span><br><span class="line"> .......<span class="comment">//下面还有很多我就不做过多重复了</span></span><br></pre></td></tr></table></figure>
<p>JS  部分</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br><span class="line">115</span><br><span class="line">116</span><br><span class="line">117</span><br><span class="line">118</span><br><span class="line">119</span><br><span class="line">120</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">var</span> num = <span class="number">0</span>;</span><br><span class="line">    <span class="keyword">var</span> sum = <span class="literal">null</span>;</span><br><span class="line">    <span class="keyword">var</span> authorurl = <span class="string">&#x27;http://qm.qq.com/cgi-bin/qm/qr?k=eIpg2LqTogTvYesXvqzEg3E9V8gnJmrb&#x27;</span>;    <span class="comment">// 作者链接</span></span><br><span class="line">    <span class="keyword">var</span> textarea = [</span><br><span class="line">        &#123; <span class="string">&#x27;text1&#x27;</span>: <span class="string">&#x27;我喜欢什么？&#x27;</span>, <span class="string">&#x27;text_1&#x27;</span>: <span class="string">&#x27;汉子&#x27;</span>, <span class="string">&#x27;text_2&#x27;</span>: <span class="string">&#x27;妹子&#x27;</span> &#125;,</span><br><span class="line">        &#123; <span class="string">&#x27;text2&#x27;</span>: <span class="string">&#x27;我最常用的头像是什么颜色？&#x27;</span>, <span class="string">&#x27;text2_1&#x27;</span>: <span class="string">&#x27;红色&#x27;</span> &#125;,</span><br><span class="line">        &#123; <span class="string">&#x27;text3&#x27;</span>: <span class="string">&#x27;我那个游戏玩的最 6 ？&#x27;</span>, <span class="string">&#x27;text3_1&#x27;</span>: <span class="string">&#x27;QQ飞车&#x27;</span> &#125;,</span><br><span class="line">        &#123; <span class="string">&#x27;text4&#x27;</span>: <span class="string">&#x27; 我 帅不帅？&#x27;</span>, <span class="string">&#x27;text4_1&#x27;</span>: <span class="string">&#x27;帅&#x27;</span>, <span class="string">&#x27;text4_2&#x27;</span>: <span class="string">&#x27;不帅&#x27;</span> &#125;</span><br><span class="line">    ];</span><br><span class="line">    <span class="comment">//--------------------------------------------------------------------------------------------------------------------</span></span><br><span class="line">    $(<span class="string">&#x27;.option header img&#x27;</span>).on(<span class="string">&#x27;click&#x27;</span>, <span class="function"><span class="keyword">function</span> (<span class="params"></span>) </span>&#123;</span><br><span class="line">        <span class="built_in">window</span>.open(authorurl);</span><br><span class="line">    &#125;)</span><br><span class="line">    $(<span class="string">&#x27;.option main a&#x27;</span>).attr(<span class="string">&#x27;href&#x27;</span>, authorurl);</span><br><span class="line"></span><br><span class="line">    <span class="keyword">var</span> text = <span class="string">&#x27;&lt;div class=&quot;problrm&quot;&gt;&lt;section&gt;&lt;span&gt;&#x27;</span> + textarea[<span class="number">0</span>].text1 + <span class="string">&#x27;&lt;/span&gt;&lt;select&gt;&lt;option value=&quot;false&quot;&gt;&#x27;</span> + textarea[<span class="number">0</span>].text_1 + <span class="string">&#x27;&lt;/option&gt;&lt;option value=&quot;true&quot;&gt;&#x27;</span> + textarea[<span class="number">0</span>].text_2 + <span class="string">&#x27;&lt;/option&gt;&lt;/select&gt;&lt;/section&gt;&lt;section&gt;&lt;span&gt;&#x27;</span> + textarea[<span class="number">1</span>].text2 + <span class="string">&#x27;&lt;/span&gt;&lt;input type=&quot;text&quot; class=&quot;text1&quot;&gt;&lt;/section&gt;&lt;section&gt;&lt;span&gt;&#x27;</span> + textarea[<span class="number">2</span>].text3 + <span class="string">&#x27;&lt;/span&gt;&lt;input type=&quot;text&quot; class=&quot;text2&quot;&gt;&lt;/section&gt;&lt;section class=&quot;dispy&quot;&gt;&lt;span&gt; &gt;&gt; 隐藏题目 &lt;&lt; &lt;/span&gt;&lt;/section&gt;&lt;button class=&quot;open&quot;&gt;开&lt;/button&gt;&lt;/div&gt;&#x27;</span>;</span><br><span class="line">    $(<span class="string">&#x27;.btn&#x27;</span>).on(<span class="string">&#x27;click&#x27;</span>, <span class="function"><span class="keyword">function</span> (<span class="params"></span>) </span>&#123;</span><br><span class="line">        <span class="keyword">var</span> winweight = $(<span class="string">&#x27;.option&#x27;</span>).height();</span><br><span class="line">        <span class="keyword">var</span> wintop = <span class="built_in">parseInt</span>($(<span class="string">&#x27;.option&#x27;</span>).css(<span class="string">&#x27;marginTop&#x27;</span>));</span><br><span class="line">        $(<span class="string">&#x27;.option&#x27;</span>).css(&#123; <span class="string">&#x27;height&#x27;</span>: (winweight + <span class="number">120</span>) + <span class="string">&#x27;px&#x27;</span>, <span class="string">&#x27;marginTop&#x27;</span>: (wintop - <span class="number">100</span>) + <span class="string">&#x27;px&#x27;</span> &#125;);</span><br><span class="line">        $(<span class="string">&#x27;main&#x27;</span>).html(text);</span><br><span class="line">        $(<span class="string">&#x27;.dispy&gt;span&#x27;</span>).on(<span class="string">&#x27;click&#x27;</span>, <span class="function"><span class="keyword">function</span> (<span class="params"></span>) </span>&#123;</span><br><span class="line">            $(<span class="built_in">this</span>).parent(<span class="string">&quot;.dispy&quot;</span>).html(<span class="string">&#x27;&lt;span&gt;&#x27;</span> + textarea[<span class="number">3</span>].text4 + <span class="string">&#x27;&lt;/span&gt;&lt;button class=&quot;btn2&quot;&gt;&#x27;</span> + textarea[<span class="number">3</span>].text4_1 + <span class="string">&#x27;&lt;/button&gt;&lt;button class=&quot;btn3&quot;&gt;&#x27;</span> + textarea[<span class="number">3</span>].text4_2 + <span class="string">&#x27;&lt;/button&gt;&#x27;</span>).css(&#123; <span class="string">&#x27;background-color&#x27;</span>: <span class="string">&#x27;transparent&#x27;</span>, <span class="string">&#x27;opacity&#x27;</span>: <span class="string">&#x27;1&#x27;</span> &#125;)</span><br><span class="line">            $(<span class="string">&#x27;.option&#x27;</span>).css(<span class="string">&#x27;height&#x27;</span>, (winweight + <span class="number">160</span>) + <span class="string">&#x27;px&#x27;</span>);</span><br><span class="line">            $(<span class="string">&#x27;.dispy&gt;span&#x27;</span>).css(<span class="string">&#x27;font-size&#x27;</span>, <span class="string">&#x27;1.2rem&#x27;</span>);</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">            $(<span class="string">&#x27;.btn2&#x27;</span>).attr(&#123; <span class="string">&#x27;index&#x27;</span>: <span class="string">&#x27;true&#x27;</span>, <span class="string">&#x27;hand&#x27;</span>: <span class="string">&#x27;true&#x27;</span> &#125;);</span><br><span class="line">            $(<span class="string">&#x27;.btn3&#x27;</span>).attr(&#123; <span class="string">&#x27;index&#x27;</span>: <span class="string">&#x27;false&#x27;</span>, <span class="string">&#x27;hand&#x27;</span>: <span class="string">&#x27;false&#x27;</span> &#125;);</span><br><span class="line"></span><br><span class="line">            $(<span class="string">&#x27;.btn2&#x27;</span>).on(<span class="string">&#x27;click&#x27;</span>, <span class="function"><span class="keyword">function</span> (<span class="params"></span>) </span>&#123;</span><br><span class="line">                sum = <span class="number">1</span>;</span><br><span class="line">                $(<span class="string">&#x27;.btn3&#x27;</span>).css(&#123; <span class="string">&quot;background-color&quot;</span>: <span class="string">&quot;white&quot;</span>, <span class="string">&quot;color&quot;</span>: <span class="string">&quot;black&quot;</span> &#125;);</span><br><span class="line">                $(<span class="built_in">this</span>).css(&#123; <span class="string">&#x27;background-color&#x27;</span>: <span class="string">&#x27;#00A2E8&#x27;</span>, <span class="string">&quot;color&quot;</span>: <span class="string">&quot;white&quot;</span> &#125;)</span><br><span class="line"></span><br><span class="line">                <span class="keyword">if</span> ($(<span class="built_in">this</span>).attr(<span class="string">&#x27;index&#x27;</span>) !== <span class="string">&#x27;true&#x27;</span>) &#123;</span><br><span class="line">                    num += <span class="number">1</span>;</span><br><span class="line">                    $(<span class="built_in">this</span>).attr(&#123; <span class="string">&#x27;index&#x27;</span>: <span class="string">&#x27;true&#x27;</span>, <span class="string">&#x27;hand&#x27;</span>: <span class="string">&#x27;true&#x27;</span> &#125;).html(textarea[<span class="number">3</span>].text4_1);</span><br><span class="line">                    $(<span class="string">&#x27;.btn3&#x27;</span>).attr(&#123; <span class="string">&#x27;index&#x27;</span>: <span class="string">&#x27;false&#x27;</span>, <span class="string">&#x27;hand&#x27;</span>: <span class="string">&#x27;false&#x27;</span> &#125;).html(textarea[<span class="number">3</span>].text4_2);</span><br><span class="line">                    <span class="keyword">if</span> (num &gt; <span class="number">3</span>) &#123;</span><br><span class="line">                        alert(<span class="string">&#x27;好了，不逗你了,重新选择吧，这次我们严肃点！&#x27;</span>);</span><br><span class="line">                        $(<span class="built_in">this</span>).attr(<span class="string">&#x27;index&#x27;</span>, <span class="string">&#x27;true&#x27;</span>);</span><br><span class="line">                        $(<span class="string">&#x27;.btn3&#x27;</span>).attr(<span class="string">&#x27;index&#x27;</span>, <span class="string">&#x27;true&#x27;</span>);</span><br><span class="line">                        num = <span class="number">0</span>;</span><br><span class="line">                    &#125;</span><br><span class="line">                &#125;</span><br><span class="line">            &#125;)</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">            $(<span class="string">&#x27;.btn3&#x27;</span>).on(<span class="string">&#x27;click&#x27;</span>, <span class="function"><span class="keyword">function</span> (<span class="params"></span>) </span>&#123;</span><br><span class="line">                sum = <span class="number">2</span>;</span><br><span class="line">                $(<span class="string">&#x27;.btn2&#x27;</span>).css(&#123; <span class="string">&quot;background-color&quot;</span>: <span class="string">&quot;white&quot;</span>, <span class="string">&quot;color&quot;</span>: <span class="string">&quot;black&quot;</span> &#125;)</span><br><span class="line">                $(<span class="built_in">this</span>).css(&#123; <span class="string">&quot;background-color&quot;</span>: <span class="string">&quot;#00A2E8&quot;</span>, <span class="string">&quot;color&quot;</span>: <span class="string">&quot;white&quot;</span> &#125;)</span><br><span class="line"></span><br><span class="line">                <span class="keyword">if</span> ($(<span class="built_in">this</span>).attr(<span class="string">&#x27;index&#x27;</span>) !== <span class="string">&#x27;true&#x27;</span>) &#123;</span><br><span class="line">                    num += <span class="number">1</span>;</span><br><span class="line">                    $(<span class="built_in">this</span>).attr(&#123; <span class="string">&#x27;index&#x27;</span>: <span class="string">&#x27;true&#x27;</span>, <span class="string">&#x27;hand&#x27;</span>: <span class="string">&#x27;true&#x27;</span> &#125;).html(textarea[<span class="number">3</span>].text4_1);;</span><br><span class="line">                    $(<span class="string">&#x27;.btn2&#x27;</span>).attr(&#123; <span class="string">&#x27;index&#x27;</span>: <span class="string">&#x27;false&#x27;</span>, <span class="string">&#x27;hand&#x27;</span>: <span class="string">&#x27;false&#x27;</span> &#125;).html(textarea[<span class="number">3</span>].text4_2);</span><br><span class="line">                    <span class="keyword">if</span> (num &gt; <span class="number">3</span>) &#123;</span><br><span class="line">                        alert(<span class="string">&#x27;好了，不逗你了,重新选择吧，这次我们严肃点！&#x27;</span>);</span><br><span class="line">                        $(<span class="built_in">this</span>).attr(<span class="string">&#x27;index&#x27;</span>, <span class="string">&#x27;true&#x27;</span>);</span><br><span class="line">                        $(<span class="string">&#x27;.btn2&#x27;</span>).attr(<span class="string">&#x27;index&#x27;</span>, <span class="string">&#x27;true&#x27;</span>);</span><br><span class="line">                        num = <span class="number">0</span>;</span><br><span class="line">                    &#125;</span><br><span class="line">                &#125;</span><br><span class="line">            &#125;)</span><br><span class="line">        &#125;)</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"></span><br><span class="line"></span><br><span class="line">        $(<span class="string">&#x27;.open&#x27;</span>).on(<span class="string">&#x27;click&#x27;</span>, <span class="function"><span class="keyword">function</span> (<span class="params"></span>) </span>&#123;</span><br><span class="line"></span><br><span class="line">            <span class="keyword">var</span> num = <span class="number">0</span>;</span><br><span class="line">            <span class="keyword">var</span> object = $(<span class="string">&#x27;.problrm select&#x27;</span>).val();</span><br><span class="line">            <span class="keyword">if</span> (object == <span class="string">&quot;true&quot;</span>) &#123;</span><br><span class="line">                num++;</span><br><span class="line">            &#125;</span><br><span class="line">            <span class="keyword">var</span> text1 = $(<span class="string">&#x27;.problrm  .text1&#x27;</span>).val();</span><br><span class="line">            <span class="keyword">if</span> (text1 == textarea[<span class="number">1</span>].text2_1) &#123;</span><br><span class="line">                num++;</span><br><span class="line">            &#125;</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">            <span class="keyword">var</span> text2 = $(<span class="string">&#x27;.problrm  .text2&#x27;</span>).val();</span><br><span class="line">            <span class="keyword">if</span> (text2 == textarea[<span class="number">2</span>].text3_1) &#123;</span><br><span class="line">                num++;</span><br><span class="line">            &#125;</span><br><span class="line">            <span class="keyword">if</span> (sum == <span class="number">1</span>) &#123;</span><br><span class="line">                <span class="keyword">if</span> ($(<span class="string">&#x27;.btn2&#x27;</span>).attr(<span class="string">&#x27;hand&#x27;</span>) === <span class="string">&#x27;true&#x27;</span>) &#123;</span><br><span class="line">                    num++;</span><br><span class="line">                &#125;</span><br><span class="line">            &#125; <span class="keyword">else</span> <span class="keyword">if</span> (sum == <span class="number">2</span>) &#123;</span><br><span class="line">                <span class="keyword">if</span> ($(<span class="string">&#x27;.btn3&#x27;</span>).attr(<span class="string">&#x27;hand&#x27;</span>) === <span class="string">&#x27;true&#x27;</span>) &#123;</span><br><span class="line">                    num++;</span><br><span class="line">                &#125;</span><br><span class="line">            &#125; <span class="keyword">else</span> &#123;</span><br><span class="line">                <span class="built_in">console</span>.log(<span class="string">&#x27;放弃题目！&#x27;</span>);</span><br><span class="line">            &#125;</span><br><span class="line"></span><br><span class="line">            <span class="keyword">if</span> (num &lt;= <span class="number">2</span> &amp;&amp; num &gt; <span class="number">0</span>) &#123;</span><br><span class="line">                $(<span class="string">&#x27;.option main&#x27;</span>).html(<span class="string">&#x27;&lt;h2&gt;1秒后跳转领取红包！&lt;/h2&gt;&#x27;</span>);</span><br><span class="line">                <span class="built_in">setTimeout</span>(<span class="function"><span class="keyword">function</span> (<span class="params"></span>) </span>&#123;</span><br><span class="line">                    <span class="built_in">window</span>.open(<span class="string">&#x27;红包链接&#x27;</span>);</span><br><span class="line">                &#125;, <span class="number">1000</span>)</span><br><span class="line">            &#125; <span class="keyword">else</span> <span class="keyword">if</span> (num == <span class="number">3</span>) &#123;</span><br><span class="line">                $(<span class="string">&#x27;.option main&#x27;</span>).html(<span class="string">&#x27;&lt;h2&gt;1秒后跳转领取红包！&lt;/h2&gt;&#x27;</span>);</span><br><span class="line">                <span class="built_in">setTimeout</span>(<span class="function"><span class="keyword">function</span> (<span class="params"></span>) </span>&#123;</span><br><span class="line">                    <span class="built_in">window</span>.open(<span class="string">&#x27;红包链接&#x27;</span>);</span><br><span class="line">                &#125;, <span class="number">1000</span>)</span><br><span class="line">            &#125; <span class="keyword">else</span> <span class="keyword">if</span> (num &gt; <span class="number">3</span>) &#123;</span><br><span class="line">                $(<span class="string">&#x27;.option main&#x27;</span>).html(<span class="string">&#x27;&lt;h2&gt;1秒后跳转领取红包！&lt;/h2&gt;&#x27;</span>);</span><br><span class="line">                <span class="built_in">setTimeout</span>(<span class="function"><span class="keyword">function</span> (<span class="params"></span>) </span>&#123;</span><br><span class="line">                    <span class="built_in">window</span>.open(</span><br><span class="line">                        <span class="string">&#x27;红包链接&#x27;</span>);</span><br><span class="line">                &#125;, <span class="number">1000</span>)</span><br><span class="line">            &#125; <span class="keyword">else</span> &#123;</span><br><span class="line">                $(<span class="string">&#x27;.option main&#x27;</span>).html(<span class="string">&#x27;&lt;h1&gt;什么？ 一个 都不会？&lt;/h1&gt;&lt;h3&gt;啧啧，我不认识你！&lt;/h3&gt;&#x27;</span>);</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;)</span><br></pre></td></tr></table></figure>
<p>大致流程就是这样</p>
<hr>
<h4 id="问题-amp-难点"><a href="#问题-amp-难点" class="headerlink" title="问题&amp;难点"></a>问题&amp;难点</h4><p>第一个问题是移动端横向滚动条，发现不管如何设置页面大小滚动条都是会出现，百度了一下找到了两个解决办法。</p>
<ul>
<li>一种是在页面加上下面的meta属性<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">&lt;meta content=<span class="string">&quot;width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no&quot;</span> name=<span class="string">&quot;viewport&quot;</span> /&gt;</span><br></pre></td></tr></table></figure></li>
<li>第二种是 给body加 <code>overflow - y ：hidden</code></li>
</ul>
<p>第二个问题是<code>button</code>按钮和<code>innput</code>输入框在Chrome点击后会出现一个蓝色的边框，看起来十分的违和。</p>
<ul>
<li>解决办法<br>在<code>button</code>上添加<code>:focus&#123;outline:0;&#125;</code>得以解决。</li>
<li>还有一个不算是问题，但是依然困扰我好久，就是关于浏览器兼容问题，写css3动画之前一直对于<code>webkit , moz , o</code>什么的没放在心上，因为之前写发现就算不写这些内核头，程序也没什么问题，但是这次在移动端发现css3动画无法运行，页面到PC端就不存在这个问题，后来加上这些就没问题啦！</li>
<li>第三个问题是<code>audio</code>音频播放器在移动端不能自动播放，需要我们人为的点击一下关闭再点击一下才能播放，原来是移动端针对这些”高消耗”的做了限制，其实也很容易理解，毕竟我国户外WiFi普及并不高大家移动端大多都是用流量，那么用户打开一个页面动辄十几兆的流量确实用户体验很差，所以这个功能是可以理解的。但是有时候我们就是需要这样的功能，该怎么办呢？<br>大多数都会使用<code>touchstart</code>,这是在网上找到的一个较为全面的写法，当然现在手机厂商众多想完全兼容也是不可能的。<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">audioAutoPlay</span>(<span class="params">id</span>) </span>&#123;</span><br><span class="line">          <span class="keyword">var</span> audio = $(<span class="string">&#x27;audio&#x27;</span>).get(<span class="number">0</span>);</span><br><span class="line">          play = <span class="function"><span class="keyword">function</span> (<span class="params"></span>) </span>&#123;</span><br><span class="line">              audio.play();</span><br><span class="line">              <span class="built_in">document</span>.removeEventListener(<span class="string">&quot;touchstart&quot;</span>, play, <span class="literal">false</span>);</span><br><span class="line">          &#125;;</span><br><span class="line">          audio.play();</span><br><span class="line">          <span class="built_in">document</span>.addEventListener(<span class="string">&quot;WeixinJSBridgeReady&quot;</span>, <span class="function"><span class="keyword">function</span> (<span class="params"></span>) </span>&#123;<span class="comment">//微信  </span></span><br><span class="line">              play();</span><br><span class="line">          &#125;, <span class="literal">false</span>);</span><br><span class="line">          <span class="built_in">document</span>.addEventListener(<span class="string">&#x27;YixinJSBridgeReady&#x27;</span>, <span class="function"><span class="keyword">function</span> (<span class="params"></span>) </span>&#123;<span class="comment">//易信  </span></span><br><span class="line">              play();</span><br><span class="line">          &#125;, <span class="literal">false</span>);</span><br><span class="line">          <span class="built_in">document</span>.addEventListener(<span class="string">&quot;touchstart&quot;</span>, play, <span class="literal">false</span>);</span><br><span class="line">      &#125;</span><br></pre></td></tr></table></figure></li>
</ul>
<blockquote>
<p>下载地址：<a target="_blank" rel="noopener" href="https://github.com/Yin63/Yin63">github</a></p>
</blockquote>

    </div>

    
    
    
        

<div>
<ul class="post-copyright">
  <li class="post-copyright-author">
    <strong>本文作者： </strong>yinks
  </li>
  <li class="post-copyright-link">
    <strong>本文链接：</strong>
    <a href="https://inkgn.gitee.io/2020/02/05/list6/" title="CSS3 制作的春节整蛊红包">https://inkgn.gitee.io/2020/02/05/list6/</a>
  </li>
  <li class="post-copyright-license">
    <strong>版权声明： </strong>本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" rel="noopener" target="_blank"><i class="fab fa-fw fa-creative-commons"></i>BY-NC-SA</a> 许可协议。转载请注明出处！
  </li>
</ul>
</div>


      <footer class="post-footer">
          <div class="post-tags">
              <a href="/tags/jquery/" rel="tag"># jquery</a>
          </div>

        


        
    <div class="post-nav">
      <div class="post-nav-item">
    <a href="/2019/05/11/list4/" rel="prev" title="一款超简约的网页级音乐播放器">
      <i class="fa fa-chevron-left"></i> 一款超简约的网页级音乐播放器
    </a></div>
      <div class="post-nav-item">
    <a href="/2020/02/19/list5/" rel="next" title="播放器 2.0 版本更新 完美适配移动端">
      播放器 2.0 版本更新 完美适配移动端 <i class="fa fa-chevron-right"></i>
    </a></div>
    </div>
      </footer>
    
  </article>
  
  
  



          </div>
          

<script>
  window.addEventListener('tabs:register', () => {
    let { activeClass } = CONFIG.comments;
    if (CONFIG.comments.storage) {
      activeClass = localStorage.getItem('comments_active') || activeClass;
    }
    if (activeClass) {
      let activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
      if (activeTab) {
        activeTab.click();
      }
    }
  });
  if (CONFIG.comments.storage) {
    window.addEventListener('tabs:click', event => {
      if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
      let commentClass = event.target.classList[1];
      localStorage.setItem('comments_active', commentClass);
    });
  }
</script>

        </div>
          
  
  <div class="toggle sidebar-toggle">
    <span class="toggle-line toggle-line-first"></span>
    <span class="toggle-line toggle-line-middle"></span>
    <span class="toggle-line toggle-line-last"></span>
  </div>

  <aside class="sidebar">
    <div class="sidebar-inner">

      <ul class="sidebar-nav motion-element">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <!--noindex-->
      <div class="post-toc-wrap sidebar-panel">
          <div class="post-toc motion-element"><ol class="nav"><li class="nav-item nav-level-3"><a class="nav-link" href="#CSS3-%E5%88%B6%E4%BD%9C%E7%9A%84%E6%98%A5%E8%8A%82%E6%95%B4%E8%9B%8A%E7%BA%A2%E5%8C%85"><span class="nav-number">1.</span> <span class="nav-text">CSS3 制作的春节整蛊红包</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#%E5%88%B6%E4%BD%9C%E6%B5%81%E7%A8%8B"><span class="nav-number">1.1.</span> <span class="nav-text">制作流程</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#%E9%97%AE%E9%A2%98-amp-%E9%9A%BE%E7%82%B9"><span class="nav-number">1.2.</span> <span class="nav-text">问题&amp;难点</span></a></li></ol></li></ol></div>
      </div>
      <!--/noindex-->

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <img class="site-author-image" itemprop="image" alt="yinks"
      src="https://blog-1253246719.cos.ap-chengdu.myqcloud.com/blog/user_info/face">
  <p class="site-author-name" itemprop="name">yinks</p>
  <div class="site-description" itemprop="description">长路漫漫，半程风雨，半程春</div>
</div>
  <div class="links-of-author motion-element">
      <span class="links-of-author-item">
        <a href="https://gitee.com/inkgn" title="Gitee → https:&#x2F;&#x2F;gitee.com&#x2F;inkgn" rel="noopener" target="_blank"><i class="fab fa-github fa-fw"></i>Gitee</a>
      </span>
      <span class="links-of-author-item">
        <a href="/2087104694@qq.com" title="E-Mail → 2087104694@qq.com"><i class="fa fa-envelope fa-fw"></i>E-Mail</a>
      </span>
  </div>



      </div>

    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer class="footer">
      <div class="footer-inner">
        

        

<div class="copyright">
  
  &copy; 
  <span itemprop="copyrightYear">2023</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">yinks</span>
</div>
  <div class="powered-by">由 <a href="https://hexo.io/" class="theme-link" rel="noopener" target="_blank">Hexo</a> & <a href="https://muse.theme-next.org/" class="theme-link" rel="noopener" target="_blank">NexT.Muse</a> 强力驱动
  </div>

        








      </div>
    </footer>
  </div>

  
  <script src="/lib/anime.min.js"></script>
  <script src="/lib/velocity/velocity.min.js"></script>
  <script src="/lib/velocity/velocity.ui.min.js"></script>

<script src="/js/utils.js"></script>

<script src="/js/motion.js"></script>


<script src="/js/schemes/muse.js"></script>


<script src="/js/next-boot.js"></script>




  















  

  

</body>
</html>
